<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/include/head.jsp"%>
<table id="dg" >
</table>

<div id="queryDialog" class="easyui-dialog" title="查询" style="width: 400px; height: 260px;"  
                 data-options="iconCls:'pag-list',modal:true,collapsible:false,minimizable:false,maximizable:false,resizable:false,closed:true,buttons:'#searchbb'">  
            <form action="" id="searchForm">
	            <table cellpadding="0" cellspacing="1" class="formtable">
				<tr>
				<td align="right"><label class="Validform_label">客户ID:</label></td>
				<td class="value">
					<input class="easyui-numberbox" type="text"  id="cusId" name="cusId"/>
				</td>
				</tr>
				<tr>
				<td align="right"><label class="Validform_label">客户姓名:</label></td>
				<td class="value">
					<input class="easyui-textbox" type="text"  id="cusName" name="cusName"/>
				</td>
				</tr>
				<tr>
				<td align="right"><label class="Validform_label">订单日期:</label></td>
				<td class="value">
					<input class="easyui-datebox" type="text"  id="orderDate" name="orderDate"/>
				</td>
				</tr>
				<tr>
				<td align="right"><label class="Validform_label">订单类型:</label></td>
				<td class="value">
					<input class="easyui-numberbox" type="text"  id="orderType" name="orderType"/>
				</td>
				</tr>
				<tr>
				<td align="right"><label class="Validform_label">总额:</label></td>
				<td class="value">
					<input class="easyui-numberbox" type="text"  id="totalAmount" name="totalAmount"/>
				</td>
				</tr>
				<tr>
				<td align="right"><label class="Validform_label">备注:</label></td>
				<td class="value">
					<input class="easyui-textbox" type="text"  id="remark" name="remark"/>
				</td>
				</tr>
				<tr>
				<td align="right"><label class="Validform_label">状态:</label></td>
				<td class="value">
					<select id="status" class="easyui-combobox" name="status" style="width:200px;" data-options="required:true">  
					<option value="" selected="selected">所有</option>
					<option value="0">未确认</option>   
					<option value="1">已确认</option>    
					<option value="5">送货中</option>  
					<option value="10">已完成</option>    
				</select>
				</td>
				</tr>
				<tr>
				<td align="right"><label class="Validform_label">概要状态:</label></td>
				<td class="value">
					<select id="statusSum" class="easyui-combobox" name="statusSum" style="width:200px;" data-options="required:true">  
					<option value="">所有</option>
					<option value="0,1,5" selected="selected">未完成</option>  
					<option value="10">已完成</option>    
				</select>
				</td>
				</tr>
	            </table>  
            </form>
            <div style="text-align:right;margin-right:30px;"  id="searchbb">
                <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="btnSearch()">查询</a>  
                <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="btnSearchCancel()">取消</a>  
            </div>                  
</div>
<script type="text/javascript">
	$(function() {
		initCurdDatagrid('orderh','dg',{
			title:'销售订单',
			dwidth:'100%',//弹出对话框的宽度 百分比或者具体数字宽度
			dheight:'100%',//弹出对话框的高度 百分比或者具体数字宽度
			baseUrl:'',
			queryParams:$("#searchForm").serializeObject(),
			sortOrder:'orderDate',
			sortOrder:'desc',
			columns:[[    
				        {field:'cusId',title:'客户ID',width:100,sortable:true,hidden:true},    
				        {field:'cusName',title:'客户姓名',width:100,sortable:true},    
				        {field:'orderDate',title:'订单日期',width:100,sortable:true,formatter:formatDate},    
				        {field:'orderType',title:'订单类型',width:100,sortable:true},    
				        {field:'totalAmount',title:'总额',width:100,sortable:true,formatter:formatDouble},    
				        {field:'remark',title:'备注',width:100,sortable:true},    
				        {field:'status',title:'状态',width:100,sortable:true,formatter:formatOrderSendStatus,styler:stylerOrderSendStatus}    
				    ]] 
		},[{
			text: '提交', 
	        iconCls: 'icon-submit', 
	        handler: function() { 
	        	var selArr = $('#dg').datagrid('getSelections');
				if(selArr.length != 1)
				{
					$.messager.alert("验证结果","请选中一行数据",'error');
					return;
				}
				var id =  selArr[0].id;
				
				$.messager.progress(); 
				KD.ajax({
	    			url:'submitOrderh.do',
	    			data:{id:id},
	    			success:function(){
	    				$.messager.alert("验证结果","提交成功",'info',function(){
	    					$('#dg').datagrid('reload');
	    					$.messager.progress('close');
	    				});
	    			}
	    		}); 
				
	        } 
		},'-',{
			text: '撤回', 
	        iconCls: 'icon-cancel', 
	        handler: function() { 
	        	var selArr = $('#dg').datagrid('getSelections');
				if(selArr.length != 1)
				{
					$.messager.alert("验证结果","请选中一行数据",'error');
					return;
				}
				var id =  selArr[0].id;
				
				$.messager.progress(); 
				KD.ajax({
	    			url:'cancelOrderh.do',
	    			data:{id:id},
	    			success:function(){
	    				$.messager.alert("验证结果","撤回成功",'info',function(){
	    					$('#dg').datagrid('reload');
	    					$.messager.progress('close');
	    				});
	    			}
	    		}); 
				
	        } 
		},'-',{
			text: '导出', 
	        iconCls: 'icon-export', 
	        handler: function() { 
	        	var selArr = $('#dg').datagrid('getSelections');
				if(selArr.length < 1)
				{
					$.messager.alert("验证结果","请选中一行数据",'error');
					return;
				}
				var ids = '';
				for(var i = 0; i < selArr.length;i++)
				{
					ids += "," + selArr[i].id;
				}
				//document.location.href="export.do?ids=" + ids.substring(1);
				window.open("${ctx}/ReportServer?reportlet=htje%2F%5B9500%5D%5B552e%5D%5B8ba2%5D%5B5355%5D.cpt&id="+ ids.substring(1));
	        } 
		},'-']);

	});
	function btnSearchCancel()
	{
		$("#queryDialog").dialog('close');  
	}
	function btnSearch()
	{ 
		$('#dg').datagrid('load',$("#searchForm").serializeObject());
		$("#queryDialog").dialog('close');
	}
	
	function reloadData()
	{
		$('#dg').datagrid('reload');
	}
	
</script>

<%@include file="/include/foot.jsp"%>